/**
 * 初始化质控病种版本详情对话框
 */
var SdsQcentityVersionInfoDlg = {
    validateFields: {
    	qcEntityId: {
            validators: {
                notEmpty: {
                    message: '质控病种ID不能为空'
                }
            }
        },
    	verCode: {
            validators: {
                notEmpty: {
                    message: '版本号不能为空'
                }
            }
        },
    	verDesc: {
            validators: {
                notEmpty: {
                    message: '版本名称不能为空'
                }
            }
        },
    	verStatus: {
            validators: {
                notEmpty: {
                    message: '版本状态（发布/未发布/作废）不能为空'
                }
            }
        },
    	startDate: {
            validators: {
                notEmpty: {
                    message: '启用日期不能为空'
                }
            }
        },
    	endDate: {
            validators: {
                notEmpty: {
                    message: '截止日期不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
SdsQcentityVersionInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
SdsQcentityVersionInfoDlg.validate = function () {
    $('#sdsQcentityVersionInfoForm').data("bootstrapValidator").resetForm();
    $('#sdsQcentityVersionInfoForm').bootstrapValidator('validate');
    return $("#sdsQcentityVersionInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
SdsQcentityVersionInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityVersionInfoForm',Sys.backendPath + "/sds/sdsqcentityversion/add",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityVersion.table.refresh();
        SdsQcentityVersionInfoDlg.close();
    });
}

/**
 * 提交修改
 */
SdsQcentityVersionInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityVersionInfoForm',Sys.backendPath + "/sds/sdsqcentityversion/update",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityVersion.table.refresh();
        SdsQcentityVersionInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("sdsQcentityVersionInfoForm", SdsQcentityVersionInfoDlg.validateFields);
});
